#encoding=utf8
'''
Created on 2019年8月22日
@author: sida
'''
from util import Node
import compute_data_pre as dtpr
import compute_lda_model as mdl
import compute_DistributionSimilarity as c_ds
import node_DistributionSimilarity as node_ds

node_intro_texts = Node(name='intro_texts',compute=c_ds.ds_index2Info,sunNodes=[node_ds.node_csvFile2Obj])
node_getLines_Seg = Node(name='Lines_Seg',compute=lambda self:[dtpr.seg_sentence(sentence)for sentence in self.sunNodes[0].getData()],sunNodes=[node_intro_texts])

node_dic = Node(name='dic',compute=mdl.computeDic,sunNodes=[node_getLines_Seg])
node_corpus = Node(name='corpus',compute=mdl.computeCorpus,sunNodes=[node_getLines_Seg,node_dic])
node_lda = Node(name='lda',compute=mdl.compute_lda,sunNodes=[node_corpus,node_dic])
node_topNlabels = Node(name='topNlabels',compute=mdl.topNlabels,sunNodes=[node_lda,node_dic])

if __name__ == '__main__':
    compulsory_Update_Nodes = [node_topNlabels]
    NoForce_Update_Nodes = []
    
    wanted_Nodes = NoForce_Update_Nodes + compulsory_Update_Nodes
    for node in compulsory_Update_Nodes:
        node.forceUpdate=True
    [print(type(node.getData())) for node in wanted_Nodes]
    
    print( len(node_dic.getData().token2id),node_dic.getData().token2id['母婴'] )
    labels = node_topNlabels.getData()
    print('母婴' in labels)
    
    
     



        
        
        
        